import React from 'react';
import { useHistory } from "react-router-dom";
import useTitle from '../../hooks/useTitle';
import { check } from '../../utils/const';
import './index.css';

function Index() {
  useTitle(Index.title);
  const history = useHistory();

  const gotoLogin = ()=>{
    history.push("/login");
    history.go(0);
  }

  const routeJump = (path)=>{
    return ()=>{
      history.push(path);
      history.go(0);};
  }

  const gotoReview = ()=>{
    check(routeJump('/review'),gotoLogin)
  }

  const gotoTest = ()=>{
    check(routeJump('/test'),gotoLogin)
  }

  const gotoStudy = ()=>{
    check(routeJump('/study'),gotoLogin)
  }

  const gotoCosplay = ()=>{
    check(routeJump('/cosplay'),gotoLogin)
  }
  return (
    <div className='index'>
      <div className='bgimg'></div>
      <div className='options'>
        <div className='option'>
          <div className='topbar'></div>
          <div className='explain'>导览展示</div>
          <div className='detail'>分科室来详细展示医院</div>
          <button className='button' onClick={gotoReview}>去体验</button>
        </div>
        <div className='option'>
        <div className='topbar'></div>
        <div className='explain'>角色扮演</div>
        <div className='detail'>扮演前台，医助，医师，了解各个职位</div>
        <button className='button'  onClick={gotoCosplay}>去扮演</button>
        </div>
        <div className='option'>
        <div className='topbar'></div>
        <div className='explain'>病例学习</div>
        <div className='detail'>这里有最全面最丰富的宠物病例</div>
        <button className='button'  onClick={gotoStudy}>去学习</button>
        </div>
        <div className='option'>
        <div className='topbar'></div>
        <div className='explain'>测试答题</div>
        <div className='detail'>对您的学习情况进行阶段性测试</div>
        <button className='button'  onClick={gotoTest}>去测试</button>
        </div>
      </div>
    </div>
  );
}

Index.path = '/index';
Index.title = '宠物医院';
Index.meta = {
    keywords:
      '宠物医院',
    description:
      '宠物医院 学习知识 线上学习'
  };
Index.exact = true;

export default Index;
